<?php $this->pageHeader('Bytt vakt'); ?>

<?php echo $this->flashMessage()->renderMessages(); ?>
<?php $filterFormUrl = $this->url(array('module' => 'core', 'controller' => 'shift-exchange', 'action' => 'select-member'), null, false); ?>

<div class="header_wrapper">
    <h1>Medlemmer</h1>
    <form method="get" action="<?php echo $filterFormUrl; ?>" method="post">
        <input type="checkbox" name="ignore_courses" id="ignore_courses" <?php echo $this->ignore_courses ? 'checked="true"' : ''; ?> onchange="submit()">
        <label for="ignore_courses">Vis uaktuelle</label>
    </form>
</div>

<form method="post" action="<?php echo $this->url(array('module' => 'core', 'controller' => 'shift-exchange', 'action' => 'exchange'), null, true); ?>">

<table class="exchange_members">
  <thead>
    <tr>
        <th>&nbsp;</th>
        <th>Navn</th>
        <th>Interesse</th>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($this->members as $member): ?>
        <?php if ($member['id'] != $this->memberId): ?>
            <?php $class = '';
            if ($member['course_count'] < $member['required_course_count']):
                $class = 'not_qualified';
            elseif ($member['interest'] == '1'):
                $class = 'interest';
            endif;
            ?>

            <tr class="<?php echo $class; ?>">
                <td class="checkbox"><input type="radio" name="member" id="<?php echo $member['id']; ?>" value="<?php echo $member['id']; ?>" /></td>
                <td><label for="<?php echo $member['id']; ?>"><?php echo $member['first_name'] . ' ' . $member['last_name']; ?></label></td>
                <td><?php echo $member['interest'] == '1' ? "Ja" : "Nei"; ?></td>
            </tr>
        <?php endif; ?>
    <?php endforeach; ?>
  </tbody>
</table>

<p>&nbsp;</p>

<input type="hidden" name="shift-role-id" value="<?php echo $this->shiftRoleId; ?>" />
<input type="hidden" name="action" value="exchange-chosen-member" />
<input type="submit" value="Bytt vakt" />
</form>
